package com.wx.mall.order.controller;


import com.wx.mall.common.api.CommonResult;
import com.wx.mall.order.entity.OrderLog;
import com.wx.mall.order.service.IOrderLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 订单日志 前端控制器
 * </p>
 *
 * @author j
 * @since 2020-04-25
 */
@RestController
@RequestMapping("/order-log")
@Api(tags = "订单操作日志",description = "OrderLogController")
@Slf4j
public class OrderLogController {

    @Resource
    private IOrderLogService service;

    @ApiOperation("根据订单id查询")
    @GetMapping("/getById")
    public CommonResult<List<OrderLog>> getById(Long orderId){

        List<OrderLog> list=service.getById(orderId);
        return CommonResult.success(list);
    };

    @ApiOperation("添加一条操作日志")
    @PostMapping("/addOne")
    public CommonResult addOne(OrderLog orderLog){
        orderLog.setOperateTime(new Date());
       boolean suceess=service.save(orderLog);
        return  suceess?CommonResult.success():CommonResult.failed();
    };
}

